package com.carl.config;

import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.plugins.PerformanceInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
@MapperScan("com.carl.mapper")
public class MybatisPlusConfig {

    private final static String dialectType = "mysql" ;

    /** mybatis-plus 分页插件 **/
    @Bean
    public PaginationInterceptor getPaginationInterceptor(){
        PaginationInterceptor interceptor = new PaginationInterceptor();
        interceptor.setDialectType(dialectType);
        return interceptor ;
    }

    /** mybatis-plus SQL执行效率插件 ***/
    /** 性能分析拦截器 ，用于输出每条SQL语句及其执行时间 **/
    @Bean
    @Profile({"dev","pro"})
    public PerformanceInterceptor getPerformanceInterceptor(){
        return new PerformanceInterceptor();
    }

}
